package com.odin.rmsservice;

import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;

import javax.sql.DataSource;
import java.sql.Connection;

/**
 * @author ICE
 */
@SpringBootApplication
@MapperScan("com.odin.rmsservice.mapper")
@EnableCaching
@EnableDiscoveryClient
@Slf4j
public class RmsServiceApplication {

    @Autowired
    DataSource dataSource;

    public static void main(String[] args) {
        SpringApplication.run(RmsServiceApplication.class, args);
    }

    public void run(String... args)throws Exception{
        showConnection();
    }

    private void showConnection() throws Exception {
        System.out.println(dataSource.toString());
        Connection conn = dataSource.getConnection();
        System.out.println(conn.toString());
        conn.close();
    }
}
